package com.stgy.lease.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * ClassName:STGYMPConfig
 * Package:com.stgy.lease.common.config
 * Description:
 *
 * @Author:helei
 * @Create:2024/8/28 - 11:20
 */
@Configuration
@MapperScan(basePackages = "com.stgy.lease.web.*.mapper")
public class STGYMPConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //创建mybatis的mp拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //创建mp内部自己的 分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setDbType(DbType.MYSQL); //设置要操作的数据库类型，默认mysql
        paginationInnerInterceptor.setOverflow(true); //设置分页合理化，如果超过的页码超过总页码 返回最后一页
        //将分页拦截器 注册给MybatisPlusInterceptor拦截器
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        //返回MybatisPlusInterceptor 注入到ioc容器中
        return interceptor;
    }


}

